﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Web.UI;
using System.Globalization;
namespace HK2009.Common
{
    public class BasePage : Page
    {
         /// <summary>
        /// 
        /// </summary>
        protected override void InitializeCulture()
        {
            base.InitializeCulture();

            if (Request.Cookies["Language"] == null)
            {
                if (Request.UserLanguages.Length > 0)
                {
                    if (Request.UserLanguages[0].ToLower().Equals("zh-hk"))
                    {
                        Thread.CurrentThread.CurrentUICulture = new CultureInfo(Config.Cht.ToLower());
                    }
                    else if (Request.UserLanguages[0].ToLower().Contains("en"))
                    {
                        Thread.CurrentThread.CurrentUICulture = new CultureInfo(Config.En.ToLower());
                    }
                    else
                    {
                        Thread.CurrentThread.CurrentUICulture = new CultureInfo(Config.Chs.ToLower());
                    }                     
                }
                else
                {
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(Config.Chs.ToLower());
                }
            }
            else
            {
                 string Language = Request.Cookies["Language"].Value;
                 if (Language.Length > 0)
                 {
                     Thread.CurrentThread.CurrentUICulture = new CultureInfo(Language);
                 }
            }
        }
    }
}
